<template>
	<view :style="themeColor" style="overflow-x: hidden;">
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center searchMall_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center searchMall_fd0_0'>
					<text class='fu-iconfont2  searchMall_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
						data-url="1">&#xE794;</text>
					<view class='flex flex-wrap align-center searchMall_fd0_0_c1'>
						<image class='searchMall_fd0_0_c1_c0' mode="aspectFit" :src='STATIC_URL+"540.png"'></image>
						<input class='flex-sub searchMall_fd0_0_c1_c1' type="text" :focus="true"
							:placeholder="`搜索你想要的商品`" confirm-type="search" :maxlength="-1"
							placeholder-style="color:#999;font-size:28rpx" @confirm="addSearchHistoryFunc()"
							v-model="keyword" />
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---搜索记录flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout searchMall_flex_1"
				style="font-family: Alimama DongFangDaKai;">
				<view class='flex flex-wrap align-center searchMall_fd1_0'>
					<text class='searchMall_fd1_0_c0'>历史搜索</text>
					<image v-if="appSearchHistory.length" class='searchMall_fd1_0_c1' :src='STATIC_URL+"541.png"'
						@click="popupShow1698293086456=true"></image>
				</view>
				<view class='flex flex-wrap align-center searchMall_fd1_1' v-if=" appSearchHistory.length>=0">
					<template v-for='(item,key0) in appSearchHistory'>
						<view class='flex flex-wrap align-center searchMall_fd1_1_c0' @tap.stop="toResult(item.name)"
							data-type="navigateTo"
							:data-url="`/pages/sousuo/recommendCommodityList/recommendCommodityList?keyword=${item.name}`"
							@longpress="handleLongpressFunc(item.name)" :key='key0'>
							<text class='searchMall_fd1_1_c0_c0' style="font-size: 26rpx;">{{item.name}}</text>
							<image class='searchMall_fd1_1_c0_c1' mode="aspectFill" :src='STATIC_URL+"198.png"'
								@tap.stop="deleteSearchHistoryFunc(item.name)" v-if=" key0==removeIndex"></image>
						</view>
					</template>

				</view>
				<text class='searchMall_fd1_2' v-if=" appSearchHistory.length<=0">暂无历史记录</text>
			</view>

			<benben-popup v-model="popupShow1698293086456" :mask="true" :mask-close-able="true" mode='center'>
				<!---删除历史记录弹窗flex布局开始-->
				<view class="flex flex-direction flex-wrap align-center search_flex_2">
					<text class='search_fd2_0'>提示</text>
					<text class='search_fd2_1'>确定删除历史记录？</text>
					<view class='flex flex-wrap align-center search_fd2_2'>
						<button class='search_fd2_2_c0' @tap.stop="popupShow1698293086456=false">取消</button>
						<button class='search_fd2_2_c1' @tap.stop="emptySearchHistoryFunc()">确认</button>
					</view>
				</view>
			</benben-popup>
			<!---flex布局flex布局开始-->
			<!-- <view v-if="hotKeywordData.length" class="flex flex-direction align-stretch benben-flex-layout"
				style="font-family: Alimama DongFangDaKai;">
				<view class='flex flex-wrap align-center searchMall_fd3_0'>
					<text class='searchMall_fd3_0_c0'>热门搜索</text>
				</view>
				<view class='flex flex-wrap align-stretch searchMall_fd3_1'>
					<view v-for="item in hotKeywordData" :key="item.aid"
						class='flex flex-wrap align-center justify-center searchMall_fd3_1_c0'
						@click="toResult(item.name)">
						<text class='searchMall_fd3_1_c0_c0' style="font-size: 30rpx;">{{item.name}}</text>
					</view>
				</view>
			</view> -->

			<!---flex布局flex布局结束-->
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout">
				<view class='flex flex-wrap align-center searchMall_fd4_0'>
					<text class='searchMall_fd4_0_c0' style="font-family: Alimama DongFangDaKai;">推荐商品</text>
				</view>
				<view class='flex flex-wrap align-stretch justify-between searchMall_fd4_1'>

					<Good v-for="(item,i) in goodsList" :key="i" :item="item" />

				</view>

				<fu-empty v-if="goodsListLoading"></fu-empty>
				<fu-empty-ui v-else-if="goodsListEmpty"></fu-empty-ui>

			</view>

		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	import Good from "@/pages/tabBar/mallPage/Good.vue"
	import {
		goodsModuleMixin
	} from './goodsModuleMixin'
	import {
		hotKeywordModuleMixin
	} from './hotKeywordModuleMixin'
	export default {
		components: {
			Good,
		},
		mixins: [goodsModuleMixin, hotKeywordModuleMixin, ],
		data() {
			return {
				"popupShow1698293086456": false,
				"keyword": "",
				"dataList": [],
				"dataLists": [],
				"removeIndex": -1,
				"keyList": []
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},
			appSearchHistory() { // 搜索历史
				return this.$store.state.appSearchHistory
			}
		},
		methods: {
			/** 去搜索结果 */
			toResult(name = "") {
				this.$store.commit('appSearchHistoryAdd', {
					"name": name
				})
				uni.navigateTo({
					url: "/pages/sousuo/goodsList/goodsList?keyword=" + name
				})
			},
			//搜索
			async searchForFunc() {
				//请求方法
				//数据验证

				let datadataList = await this.$api.get(global.apiUrls.post641af9cb8b32f, {
					view_position: 'all'
				});

				if (datadataList.data.code != 1) {
					this.$message.info(datadataList.data.msg);
					return
				}
				let infodataList = datadataList.data;
				this.dataList = infodataList.data
			},
			//长按事件
			handleLongpressFunc(index) {
				this.removeIndex = index;
			},
			//添加搜索历史
			addSearchHistoryFunc() {
				this.$store.commit('appSearchHistoryAdd', {
					"name": this.keyword
				})
				uni.navigateTo({
					url: "/pages/sousuo/goodsList/goodsList?keyword=" + this.keyword
				})
			},
			//删除搜索历史
			deleteSearchHistoryFunc(name) {
				this.$store.commit('appSearchHistoryDel', {
					"name": name
				})
			},
			//清空搜索记录
			emptySearchHistoryFunc() {
				this.$store.commit('appSearchHistoryClean', '')
				this.popupShow1698293086456 = false;
			},
			//获取猜你想搜列表
			async getKeyListFunc() {
				//请求方法
				//数据验证

				let datakeyList = await this.$api.post(global.apiUrls.post6444e7f87e459, {

				});

				if (datakeyList.data.code != 1) {
					this.$message.info(datakeyList.data.msg);
					return
				}
				let infokeyList = datakeyList.data;
				this.keyList = infokeyList.data
			}
		}
	};
</script>
<style lang="scss" scoped>
	.search_flex_2 {
		background: #fff;
		margin: 0rpx 105rpx 0rpx 105rpx;
		background-size: #eee;
		border-radius: 25rpx 25rpx 25rpx 25rpx;
		padding: 40rpx 0rpx 0rpx 0rpx;
	}

	.search_fd2_2_c1 {
		background: transparent;
		line-height: 90rpx;
		border-radius: 0rpx 0rpx 16rpx 0rpx;
		font-size: 32rpx;
		color: #47AAEE;
		width: 269rpx;
		height: 90rpx;
	}

	.search_fd2_2_c0 {
		border-right: 1px solid #EEEEEE;
		background: transparent;
		line-height: 90rpx;
		border-radius: 0rpx 0rpx 0rpx 16rpx;
		font-size: 32rpx;
		color: #999;
		height: 90rpx;
		width: 270rpx;
	}

	.search_fd2_2 {
		border-top: 1px solid #eee;
	}

	.search_fd2_1 {
		font-size: 32rpx;
		font-weight: 500;
		color: #333333;
		margin: 48rpx 0rpx 60rpx 0rpx;
	}

	.search_fd2_0 {
		color: #333333;
		font-size: 36rpx;
		font-weight: 500;
		line-height: 45rpx;
	}

	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: var(--benbenbgColor1);
		background-size: 100% auto;
	}

	.searchMall_flex_0 {
		width: 750rpx;
		height: 120rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.searchMall_fd0_0_c1_c1 {
		margin: 0rpx 0rpx 0rpx 16rpx;
		font-size: 24rpx;
		font-weight: 400;
		color: #333;
		width: 100%;
	}

	.searchMall_fd0_0_c1_c0 {
		width: 32rpx;
		height: 32rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.searchMall_fd0_0_c1 {
		background: #f8f8f8;
		background-size: 100% auto !important;
		border-radius: 36rpx 36rpx 36rpx 36rpx;
		width: 436rpx;
		height: 64rpx;
		margin: 0rpx 0rpx 0rpx 24rpx;
		padding: 0rpx 24rpx 0rpx 24rpx;
	}

	.searchMall_fd0_0_c0 {
		font-size: 36rpx;
		color: #333;
		font-weight: 500;
	}

	.searchMall_fd0_0 {
		padding: 0 32rpx;
	}

	.searchMall_flex_1 {
		background: #FFFFFF;
		padding: 0rpx 0rpx 0rpx 0rpx;
		border-radius: 24rpx 24rpx 0rpx 0rpx;
		margin: 0rpx 0rpx 0rpx 0rpx;
	}

	.searchMall_fd1_2 {
		font-size: 24rpx;
		font-weight: 400;
		color: #666666;
		margin: 0rpx 0rpx 32rpx 24rpx;
	}

	.searchMall_fd1_1_c0_c1 {
		width: 18rpx;
		height: 18rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.searchMall_fd1_1_c0_c0 {
		font-size: 24rpx;
		font-weight: 400;
		color: rgba(51, 51, 51, 1);
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.searchMall_fd1_1_c0 {
		background: rgba(247, 246, 244, 1);
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		background-size: 100% auto !important;
		padding: 0rpx 40rpx 0rpx 40rpx;
		line-height: 56rpx;
		margin: 0rpx 12rpx 24rpx 12rpx;
	}

	.searchMall_fd1_1 {
		padding: 0rpx 0rpx 0rpx 18rpx;
	}

	.searchMall_fd1_0_c1 {
		width: 28rpx;
		height: 32rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 0rpx 0rpx auto;
	}

	.searchMall_fd1_0_c0 {
		font-size: 32rpx;
		font-weight: 700;
		color: #333333;
	}

	.searchMall_fd1_0 {
		padding: 32rpx 0rpx 24rpx 0rpx;
		margin: 0rpx 24rpx 0rpx 24rpx;
	}

	.searchMall_fd2_0_c0_c2_c1_c0 {
		color: #FFFFFF;
		font-size: 34rpx;
		font-weight: 400;
	}

	.searchMall_fd2_0_c0_c2_c1 {
		background: url(https://www.guochaoxiaoju.com/uploads/mini/694.png) no-repeat;
		height: 71rpx;
		width: 191rpx;
		margin: 0rpx 0rpx 0rpx 16rpx;
		background-size: 100% auto;
	}

	.searchMall_fd2_0_c0_c2_c0_c0 {
		color: #796446;
		font-size: 34rpx;
		font-weight: 400;
	}

	.searchMall_fd2_0_c0_c2_c0 {
		background: url(https://www.guochaoxiaoju.com/uploads/mini/693.png) no-repeat;
		height: 71rpx;
		width: 191rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
		background-size: 100% auto;
	}

	.searchMall_fd2_0_c0_c2 {
		margin: 0rpx 0rpx 70rpx 0rpx;
	}

	.searchMall_fd2_0_c0_c1 {
		line-height: 44rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
		margin: 40rpx 0rpx 71rpx 0rpx;
		text-align: center;
	}

	.searchMall_fd2_0_c0_c0 {
		color: #333333;
		font-size: 40rpx;
		font-weight: 400;
		margin: 190rpx 0rpx 0rpx 0rpx;
	}

	.searchMall_fd2_0 {
		background: url(https://www.guochaoxiaoju.com/uploads/mini/692.png) no-repeat;
		width: 580rpx;
		background-size: 100% auto;
	}

	.searchMall_fd3_1_c0_c0 {
		color: #333333;
		font-size: 28rpx;
		font-weight: 400;
		line-height: 40rpx;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.searchMall_fd3_1_c0 {
		background: #F7F6F4;
		margin: 0rpx 0rpx 32rpx 0rpx;
		border-radius: 35rpx;
		padding: 12rpx 32rpx 12rpx 32rpx;
		margin-right: 24rpx;
	}

	.searchMall_fd3_1 {
		width: 687rpx;
		margin: 0rpx auto 0rpx auto;
	}

	.searchMall_fd3_0_c0 {
		font-size: 32rpx;
		font-weight: 700;
		color: rgba(51, 51, 51, 1);
	}

	.searchMall_fd3_0 {
		padding: 32rpx 0rpx 15rpx 0rpx;
		margin: 0rpx 30rpx 32rpx 30rpx;
	}

	.searchMall_fd4_1_c0_c1_c2_c2 {
		color: #999999;
		font-size: 24rpx;
		font-weight: 400;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		max-width: 110rpx;
		margin: 0rpx 0rpx 0rpx auto;
		padding-bottom: calc(32rpx + env(safe-area-inset-bottom));
	}

	.searchMall_price2_fd4_1_c0_c1_c2_c1 {
		font-size: 22rpx;
	}

	.searchMall_price1_fd4_1_c0_c1_c2_c1 {
		font-size: 34rpx;
	}

	.searchMall_fd4_1_c0_c1_c2_c1 {
		color: rgba(173, 56, 35, 1);
		font-weight: 600;
	}

	.searchMall_fd4_1_c0_c1_c2_c0 {
		color: rgba(173, 56, 35, 1);
		font-weight: 700;
		font-size: 24rpx;
	}

	.searchMall_fd4_1_c0_c1_c1 {
		color: #999999;
		font-size: 22rpx;
		font-weight: 400;
		margin: 0rpx 0rpx 12rpx 0rpx;
		text-decoration: line-through;
	}

	.searchMall_fd4_1_c0_c1_c0 {
		color: #333333;
		font-size: 28rpx;
		font-weight: 400;
		padding: 20rpx 0rpx 20rpx 0rpx;
		line-height: 40rpx;
	}

	.searchMall_fd4_1_c0_c1 {
		padding: 0rpx 20rpx 0rpx 20rpx;
	}

	.searchMall_fd4_1_c0_c0 {
		width: 335rpx;
		height: 350rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.searchMall_fd4_1_c0 {
		background: #FFFFFF;
		padding: 0rpx 0rpx 24rpx 0rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		box-shadow: 0rpx 3rpx 16rpx 1rpx rgba(0, 0, 0, 0.1);
	}

	.searchMall_fd4_1 {

		width: 100%;
		padding: 0 24rpx;
	}

	.searchMall_fd4_0_c0 {
		font-size: 32rpx;
		font-weight: 700;
		color: rgba(51, 51, 51, 1);
	}

	.searchMall_fd4_0 {
		padding: 32rpx 0rpx 15rpx 0rpx;
		margin: 0rpx 30rpx 16rpx 30rpx;
	}

	::v-deep .mallPage_fd1_0_c4_c1_c0 {
		box-shadow: 0 0 10rpx 1rpx #eee;
	}
</style>